<template>
	<view class="container">
		<input v-model="filterText" placeholder="请输入"/>
		
		<view class="list" v-if="isshow">
			<view class="opt" v-for="(item, index) in filterList" :key="index">{{item}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isshow: true,
				filterText: '',
				list: [
					'就的分v开具发',
					'东方华府高度',
					'还是分VB的上班',
					'军大口径发的是',
					'好激动反间谍法',
					'都股份hi肉素',
					'标点符号舞蹈服',
					'东方红VG的事件',
					'的红包放到',
					'djfhdsfsd f',
					'的积分GV首都发生的',
					'地方接换肤大师',
					'的巨幅的所肩负的'
				],
				filterList: []
			}
		},
		watch: {
			filterText(val, oldVal) {
				if (val.length == 0) {
					this.isshow = false
				} else {
					this.isshow = true;
					var list = []
					this.list.forEach((item, index) => {
						if (item.indexOf(val) >= 0) {
							list.unshift(item)
						}
					})
					this.filterList = list;
				}
			}
		},
	}
</script>

<style lang="scss" scoped>
	.container{
		input{
			border: 2rpx solid #333;
		}
	}
</style>
